<?php
session_start();

require_once("../database.include.php");

	$groupName=$_GET["groupName"];
	//$userName=$_SESSION['username']; //TODO: ensure current user is a member of group
	
	$retValue = "";

	/* Delete all rows from the group table */
	$count = $conn->exec("DELETE FROM `group` WHERE `name` = '" . $groupName . "'");
	/* Return number of rows that were deleted */
	echo "Deleted $count rows in group.\n";
	$retValue .= "Deleted $count rows in group.\n";

	/* Delete all rows from the group_user table */
	$count = $conn->exec("DELETE FROM `group_user` WHERE `group_name` = '" . $groupName . "'");
	/* Return number of rows that were deleted */
	echo "Deleted $count rows in group_user.\n";
	$retValue .= "Deleted $count rows in group_user.\n";

	/* Delete all rows from the message table */
	$count = $conn->exec("DELETE FROM `message` WHERE `group_name` = '" . $groupName . "'");
	/* Return number of rows that were deleted */
	echo "Deleted $count rows in message.\n";
	$retValue .= "Deleted $count rows in message.\n";

	/* Delete all rows from the group_invitation table */
	$count = $conn->exec("DELETE FROM `group_invitation` WHERE `group_name` = '" . $groupName . "'");
	/* Return number of rows that were deleted */
	echo "Deleted $count rows in group_invitation.\n";
	$retValue .= "Deleted $count rows in group_invitation.\n";
	
	return $retValue;

?>
